

/* Appendix Figure 3 Income Gradient BEGIN */


use cps_voting_90, clear
keep if age >24 & age < 65

keep if year==1992
*** This is the 1990s data ****
rename faminc f_income
gen inc_ten = 0 if f_income==100
replace inc_ten = 1 if f_income==210 | f_income==300 /*5000-10000*/
replace inc_ten = 2 if f_income==430 | f_income==470 /*10000-15000*/
replace inc_ten = 3 if f_income==500 /*15000-20000*/
replace inc_ten = 4 if f_income==600  /*20000-25000*/
replace inc_ten = 5 if f_income==710  /*25000-30000*/
replace inc_ten = 6 if f_income==720 /*30000-35000*/
replace inc_ten = 7 if f_income==730 /*35000-40000*/
replace inc_ten = 8 if f_income==740 /*40000-50000*/
replace inc_ten = 9 if f_income==820 /*50000-60000*/
replace inc_ten = 10 if f_income==830 /*60000-75000*/

/********************************************************************
This provides parent's voting and avghhincome prior to casino
********************************************************************/

*keep if race ~= 100
*keep if race == 100
*keep if year ==1992

gen voted_nc = voted if state ==37
gen nc_state=1 if state==37
replace nc_state=0 if state!=37
bysort inc_ten: egen mean_vote_inc_nc=mean(voted_nc)
bysort inc_ten: egen mean_vote_inc=mean(voted)

bysort inc_ten nc_state: gen index_nc_state=1 if _n==1

keep if index_nc_state==1
*bysort inc_ten year: gen index_inc=1 if _n==1

reg mean_vote_inc inc_ten

*keep if index_inc==1

save temp_a_es, replace



use temp_a_es, clear
append using temp_b
*** Note that temp_b comes from parent_eventanalysis 100118.do file ***
***try this graph with NC and GSMS only
keep if inc_ten<10|av_inc<10
*twoway (scatter mean_vote_inc av_inc) (scatter mean_vote_inc_nc inc_ten if index_nc_state==1&nc_state==1) (lpoly mean_vote_inc av_inc) (lpoly mean_vote_inc_nc inc_ten if nc_state==1) if inc_ten>0&av_inc>0&av_inc!=10&inc_ten!=10


**formatted graph

#d;
twoway (scatter mean_vote_inc_nc inc_ten if index_nc_state==1&nc_state==1, ms(circle_hollow) mcolor(gray)) (scatter mean_vote_inc av_inc, mcolor(black)) 
(lpoly mean_vote_inc av_inc, lcolor(black) ) (lpoly mean_vote_inc_nc inc_ten if nc_state==1, lcolor(gray) ) if inc_ten>0&av_inc>0&av_inc!=10&inc_ten!=10,
  graphregion(color(white)) 
       plotregion(color(white))
	   aspect(1.00)
       ysize(3.5)
	   yscale(range(0.15(0.1)0.70))
	   ylabel(0.15(0.1)0.70, nogrid)
       xlabel(0 "0" 1 "5" 2 "10" 3 "15" 4 "20" 5 "25" 6 "30" 7 "35" 8 "40" 9 "50", labsize(small)  glwidth(vthin) glpattern(shortdash) glcolor(gs13) nogmin)
       xtitle("{fontface Times New Roman:Average Household Income in $1000s}")
       ytitle("{fontface Times New Roman:Mean Voting}")
	   legend(on row(1) order(1 "North Carolina" 2 "GSMS") position(6));

	   
	   graph save parents_initial_income_cps_final.gph, replace;


/* Appendix Figure 3 Income Gradient END */


	
/* Appendix Figure 4 First Stage Income BEGIN */
* Income First Stage *
cd "$dir"
clear
clear mata
clear matrix
set maxvar 20000
use gsms_diff_diff_nocollapse_082817.dta, clear

drop _merge

merge m:1 gsmsid wave using inc_alone

tab wave, gen(wv)

gen agt=1 if ag1==1 | ag2==1
recode agt . =0 if ag3==1
drop ag1
gen ag1 = agt

gen int1=wv1*pa*ag1
gen int2=wv2*pa*ag1
gen int3=wv3*pa*ag1
gen int4=wv4*pa*ag1
gen int5=wv5*pa*ag1
gen int6=wv6*pa*ag1
gen int7=wv7*pa*ag1
gen int8=wv8*pa*ag1


xi:reg inc_dollars2 int1-int3 int5-int8   i.pa*i.agegrup  i.wave i.wave*i.agegrup pa if age <18 ,  r cluster(gsms)
parmest, label list(parm label estimate min* max* p) level(95) saving(results, replace)
use results, clear
keep if _n<8
set obs 8
replace parm ="int4" in 8
destring parm, gen(parm2) ignore("int")
drop parm
rename parm2 parm
sort parm
replace estimate =0 if parm ==4
label variable estimate "Regression Coefficient"
label variable min95 "Lower 95% CI"
label variable max95 "Upper 95% CI"

#d;
twoway (line estimate parm, mcolor(black) msymbol(square) msize(small)) (rcap min95 max95 parm, lcolor(black)), 
yline(0, lp(dash) lcolor(red))
       graphregion(color(white)) 
       plotregion(color(white))
       aspect(.35)
       ysize(3.5)
       xlabel(1 "-3" 2 "-2" 3 "-1" 4 "0" 5 "1" 6 "2" 7 "3" 8 "4", labsize(small) grid glwidth(vthin) glpattern(shortdash) glcolor(gs13) nogmin)
       xtitle("{fontface Helvetica:Years}")
       ytitle("{fontface Helvetica:Estimated Coefficient}") 
       title("{fontface Helvetica:Coefficients on American Indian Parents and Income}", size(medium) pos(11)) clegend(on ring(0));
graph save pretrend_parents_voting.gph, replace;
#d cr
restore
/* Appendix Figure 4 First Stage Income END */




/* Appendix Figure 5 Cash on Income Quartiles for Parents BEGIN */
use parents, clear


gen inter_triple = after*ai_par_tt*avghhincome
gen ai_par_tt_inc = avghhincome*ai_par_tt
gen after_inc = after*avghhincome



encode gsmsid, gen(newid)
xtset newid year



xtile triple =avghhincome_new, n(4)
*** Gives the cutoffs here ***
bysort triple: sum avghhincome_new


reg votedtotal  interaction after ai_par_tt i.year  ag1_new ag2_new  if year>1990 & avghhincome<=3.33,   cl(gsms) r 
reg votedtotal  interaction after ai_par_tt i.year  ag1_new ag2_new  if year>1990 & avghhincome>3.33 & avghhincome<=5.33,  cl(gsms) r 
reg votedtotal  interaction after ai_par_tt i.year  ag1_new ag2_new  if year>1990 & avghhincome>5.33 & avghhincome<=8.33 ,  cl(gsms) r 
reg votedtotal  interaction after ai_par_tt i.year  ag1_new ag2_new  if year>1990 & avghhincome>8.33  ,  cl(gsms) r 

/*
*** output from above, copied and pasted from the results for interaction
saved as par_quartiles
"parm"	estimate	stderr	min95	max95
first	-0.031044	0.0215384	-0.0734148	0.0113267
second	-0.0113031	0.0369153	-0.0839296	0.0613235
third	-0.0007704	0.026946	-0.0537695	0.0522287
fourth	0.0310688	0.0368611	-0.0414262	0.1035637
*/


preserve
use par_quartiles, clear
#d;
twoway   (rcap min95 max95 parm, lcolor(black)), 
yline(0, lp(dash) lcolor(red))
       graphregion(color(white)) 
       plotregion(color(white))
       aspect(.35)
       ysize(3.5)
	   ylabel(,nogrid)
       xlabel(1 "0-25" 2 "26-50" 3 "51-75" 4 "76-100", labsize(small)   nogmin)
       xtitle("{fontface Helvetica:Initial Household Income in Quartiles}")
       ytitle("{fontface Helvetica:Estimated Coefficient}");
graph save parents_quartile_ever.gph, replace;
#d cr
restore



/* Appendix Figure 5 Cash on Income Quartiles for Parents END */






/* Appendix Figure 6 Cash on Income Quartiles for Children BEGIN */
****************************** Results, Unweighted, With Baseline Vote Propensity (in in-text table and figure)
use temp, clear
 
/* Children's Regressions by Quartiles */ 

xtile triple =avghhincome_new if parent ==0, n(4)
tab triple, gen(tr)
drop aa1 aa2 ai_inc ag1_inc ag2_inc
gen t1_triple = ag1*ai_par_t_new
gen ai_inc1=ai_par_t_new*tr1
gen ai_inc2=ai_par_t_new*tr2
gen ai_inc3=ai_par_t_new*tr3
gen ai_inc4=ai_par_t_new*tr4
gen ag1_inc1=ag1*tr1
gen ag1_inc2=ag1*tr2
gen ag1_inc3=ag1*tr3
gen ag1_inc4=ag1*tr4
gen aa1 = ag1*ai_par_t_new*tr1
gen aa2 = ag1*ai_par_t_new*tr2
gen aa3 = ag1*ai_par_t_new*tr3
gen aa4 = ag1*ai_par_t_new*tr4




reg ever_vote t1_triple  ai_par_t_new        sex_new less6_new age_days_1_1_1992   parent_base_prop_vote if parent==0 & avghhincome<=3.33, r
outreg2 using kids_voting.xls, replace keep(t1_triple)
reg ever_vote t1_triple ai_par_t_new        sex_new less6_new age_days_1_1_1992   parent_base_prop_vote if parent==0 & avghhincome>3.33 & avghhincome<=5.33 , r
outreg2 using kids_voting.xls, append keep(t1_triple)
reg ever_vote t1_triple ai_par_t_new        sex_new less6_new age_days_1_1_1992   parent_base_prop_vote if parent==0 & avghhincome>5.33 & avghhincome<=8.33 , r
outreg2 using kids_voting.xls, append keep(t1_triple)
reg ever_vote t1_triple ai_par_t_new        sex_new less6_new age_days_1_1_1992   parent_base_prop_vote if parent==0 & avghhincome>8.33  , r
outreg2 using kids_voting.xls, append keep(t1_triple)

/*
Ever Vote					
parm		estimate	stderr	min95	max95	min90	max90
1	First Quartile	0.182	0.0723	0.040292	0.323708	0.063428	0.300572
2	Second Quartile	0.195	0.101	-0.00296	0.39296	0.02936	0.36064
3	Third Quartile	-0.0183	0.157	-0.32602	0.28942	-0.27578	0.23918
4	Fourth Quartile	-0.147	0.18	-0.4998	0.2058	-0.4422	0.1482
save parm, replace
*/

preserve
use parm, clear
#d;
twoway (line estimate parm, mcolor(black) msymbol(square) msize(small))  (rcap min90 max90 parm, lcolor(black)), 
yline(0, lp(dash) lcolor(red))
       graphregion(color(white)) 
       plotregion(color(white))
       aspect(.35)
       ysize(3.5)
       xlabel(1 "0-25" 2 "26-50" 3 "51-75" 4 "76-100", labsize(small) grid glwidth(vthin) glpattern(shortdash) glcolor(gs13) nogmin)
       xtitle("{fontface Helvetica:Initial Household Income in Quartiles}")
       ytitle("{fontface Helvetica:Estimated Coefficient}")
	   title("{fontface Helvetica: Effect of Payments in Each Household Income Quartile}")
	   subtitle("{fontface Helvetica: for Ever Voted}");
graph save children_quartile_ever.gph, replace;
#d cr
restore




reg prop_vote t1_triple  ai_par_t_new        sex_new less6_new age_days_1_1_1992   parent_base_prop_vote if parent==0 & avghhincome<=3.33, r
outreg2 using kids_voting.xls, append keep(t1_triple)
reg prop_vote t1_triple ai_par_t_new        sex_new less6_new age_days_1_1_1992   parent_base_prop_vote if parent==0 & avghhincome>3.33 & avghhincome<=5.33 , r
outreg2 using kids_voting.xls, append keep(t1_triple)
reg prop_vote t1_triple ai_par_t_new        sex_new less6_new age_days_1_1_1992   parent_base_prop_vote if parent==0 & avghhincome>5.33 & avghhincome<=8.33 , r
outreg2 using kids_voting.xls, append keep(t1_triple)
reg prop_vote t1_triple ai_par_t_new        sex_new less6_new age_days_1_1_1992   parent_base_prop_vote if parent==0 & avghhincome>8.33  , r
outreg2 using kids_voting.xls, append keep(t1_triple)

/*
Prop Vote							
parm		estimate	stderr	min95	max95	min90	max90
1	First Quartile	0.0861	0.0341	0.019264	0.152936	0.030176	0.142024
2	Second Quartile	0.107	0.0593	-0.009228	0.223228	0.009748	0.204252
3	Third Quartile	0.0875	0.0835	-0.07616	0.25116	-0.04944	0.22444
4	Fourth Quartile	-0.159	0.11	-0.3746	0.0566	-0.3394	0.0214
save parm2, replace
*/

preserve
use parm2, clear
#d;
twoway (line estimate parm, mcolor(black) msymbol(square) msize(small)) 
  (rcap min90 max90 parm, lcolor(black)), 
yline(0, lp(dash) lcolor(red))
       graphregion(color(white)) 
       plotregion(color(white))
       aspect(.35)
       ysize(3.5)
       xlabel(1 "0-25" 2 "26-50" 3 "51-75" 4 "76-100", labsize(small) grid glwidth(vthin) glpattern(shortdash) glcolor(gs13) nogmin)
       xtitle("{fontface Helvetica:Initial Household Income in Quartiles}")
       ytitle("{fontface Helvetica:Estimated Coefficient}")
	   title("{fontface Helvetica: Effect of Payments in Each Household Income Quartile}")
	   subtitle("{fontface Helvetica: for Proprotion Elections Voted}");
graph save children_quartile_prop.gph, replace;
#d cr
restore

graph combine children_quartile_ever.gph children_quartile_prop.gph, col(1) ysize(8) xsize(6)    graphregion(color(white)) plotregion(color(white)) ycommon

/* Appendix Figure 6 Cash on Income Quartiles for Children END */


/* Appendix Figure 7 Parents Voting Event Analysis BEGIN */

use parents, clear

preserve
*** Cohorts by Race by After by Year Triple Difference ***
************ Appendix Figure 3 *************************
reg votedtotal  intc1 intc2  intc4-intc12   ai_par_tt i.year year i.race_yr i.race_agegrup i.yr_agegrup ag1 avghhincome_new if year >1990,  cl(gsms)
parmest, label list(parm label estimate min* max* p) level(95) saving(results, replace)
use results, clear
keep if _n<12
set obs 12
replace parm ="intc3" in 12
destring parm, gen(parm2) ignore("intc")
drop parm
rename parm2 parm
sort parm
replace estimate =0 if parm ==3
label variable estimate "Regression Coefficient"
label variable min95 "Lower 95% CI"
label variable max95 "Upper 95% CI"

#d;
twoway (line estimate parm, mcolor(black) msymbol(square) msize(small)) (rcap min95 max95 parm, lcolor(black)), 
yline(0, lp(dash) lcolor(red))
       graphregion(color(white)) 
       plotregion(color(white))
       aspect(.35)
       ysize(3.5)
       xlabel(1 "1992" 2 "1994" 3 "1996" 4 "1998" 5 "2000" 6 "2002" 7 "2004" 8 "2006" 9 "2008" 10 "2010" 11 "2012" 12 "2014", labsize(small) grid glwidth(vthin) glpattern(shortdash) glcolor(gs13) nogmin)
       xtitle("{fontface Helvetica:Years}")
       ytitle("{fontface Helvetica:Estimated Coefficient}") 
       title("{fontface Helvetica:Difference in Cohorts on American Indian Parents for Voting}", size(medium) pos(11)) clegend(on ring(0));
graph save pretrend_parents_voting.gph, replace;
#d cr
restore


preserve
*** Cohorts by Race by After by Year Triple Difference ***
************ Appendix Figure 3 *************************
reg votedtotal  intc1 intc2  intc4-intc12   ai_par_tt i.year year i.race_yr i.race_agegrup i.yr_agegrup ag1 if year >1990 & avghhincome_new<=5.33,  cl(gsms)
parmest, label list(parm label estimate min* max* p) level(95) saving(results, replace)
use results, clear
keep if _n<12
set obs 12
replace parm ="intc3" in 12
destring parm, gen(parm2) ignore("intc")
drop parm
rename parm2 parm
sort parm
replace estimate =0 if parm ==3
label variable estimate "Regression Coefficient"
label variable min95 "Lower 95% CI"
label variable max95 "Upper 95% CI"

#d;
twoway (line estimate parm, mcolor(black) msymbol(square) msize(small)) (rcap min95 max95 parm, lcolor(black)), 
yline(0, lp(dash) lcolor(red))
       graphregion(color(white)) 
       plotregion(color(white))
       aspect(.35)
       ysize(3.5)
       xlabel(1 "1992" 2 "1994" 3 "1996" 4 "1998" 5 "2000" 6 "2002" 7 "2004" 8 "2006" 9 "2008" 10 "2010" 11 "2012" 12 "2014", labsize(small) grid glwidth(vthin) glpattern(shortdash) glcolor(gs13) nogmin)
       xtitle("{fontface Helvetica:Years}")
       ytitle("{fontface Helvetica:Estimated Coefficient}") 
       title("{fontface Helvetica:Difference in Cohorts on American Indian Parents for Voting Below Median Inc}", size(medium) pos(11)) clegend(on ring(0));
graph save pretrend_parents_voting.gph, replace;
#d cr
restore

preserve
*** Cohorts by Race by After by Year Triple Difference ***
************ Appendix Figure 3 *************************
reg votedtotal  intc1 intc2  intc4-intc12   ai_par_tt i.year year i.race_yr i.race_agegrup i.yr_agegrup ag1 if year >1990 & avghhincome_new>5.33 & avghhincome<.,  cl(gsms)
parmest, label list(parm label estimate min* max* p) level(95) saving(results, replace)
use results, clear
keep if _n<12
set obs 12
replace parm ="intc3" in 12
destring parm, gen(parm2) ignore("intc")
drop parm
rename parm2 parm
sort parm
replace estimate =0 if parm ==3
label variable estimate "Regression Coefficient"
label variable min95 "Lower 95% CI"
label variable max95 "Upper 95% CI"

#d;
twoway (line estimate parm, mcolor(black) msymbol(square) msize(small)) (rcap min95 max95 parm, lcolor(black)), 
yline(0, lp(dash) lcolor(red))
       graphregion(color(white)) 
       plotregion(color(white))
       aspect(.35)
       ysize(3.5)
       xlabel(1 "1992" 2 "1994" 3 "1996" 4 "1998" 5 "2000" 6 "2002" 7 "2004" 8 "2006" 9 "2008" 10 "2010" 11 "2012" 12 "2014", labsize(small) grid glwidth(vthin) glpattern(shortdash) glcolor(gs13) nogmin)
       xtitle("{fontface Helvetica:Years}")
       ytitle("{fontface Helvetica:Estimated Coefficient}") 
       title("{fontface Helvetica:Difference in Cohorts on American Indian Parents for Voting Above Median Inc}", size(medium) pos(11)) clegend(on ring(0));
graph save pretrend_parents_voting.gph, replace;
#d cr
restore



/* Appendix Figure 7 Parents Voting Event Analysis END */
